Public API for Custom Operators with Factory Helpers#1106
Draft
samwillis wants to merge 2 commits intoclaude/auto-register-operators-016i3ACKCCt2WbkPRApMpqjufrom
Draft
Public API for Custom Operators with Factory Helpers#1106samwillis wants to merge 2 commits intoclaude/auto-register-operators-016i3ACKCCt2WbkPRApMpqjufrom
samwillis wants to merge 2 commits intoclaude/auto-register-operators-016i3ACKCCt2WbkPRApMpqjufrom
Conversation
|
| Name | Type |
|---|---|
| @tanstack/db | Patch |
| @tanstack/angular-db | Patch |
| @tanstack/electric-db-collection | Patch |
| @tanstack/offline-transactions | Patch |
| @tanstack/powersync-db-collection | Patch |
| @tanstack/query-db-collection | Patch |
| @tanstack/react-db | Patch |
| @tanstack/rxdb-db-collection | Patch |
| @tanstack/solid-db | Patch |
| @tanstack/svelte-db | Patch |
| @tanstack/trailbase-db-collection | Patch |
| @tanstack/vue-db | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
01b917f to
98b251a
Compare
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Contributor
|
Size Change: +467 B (+0.48%) Total Size: 97.2 kB
ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 3.35 kB ℹ️ View Unchanged
|
be91eeb to
dd23147
Compare
KyleAMathews
approved these changes
Jan 8, 2026
Collaborator
KyleAMathews
left a comment
There was a problem hiding this comment.
Looks good! Merge (double-merge) away!
Collaborator
|
chatgpt's review https://chatgpt.com/share/6960421c-26c4-800c-af32-2ae0f8ce98a8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
stacked on #944
PR: Public API for Custom Operators with Factory Helpers
Summary
This PR adds a clean public API (
defineOperator,defineAggregate) for users to create custom operators and aggregates, along with factory helpers that reduce boilerplate for common patterns.Changes
New Files
define.ts- Public API fordefineOperatoranddefineAggregatefactories.ts- Factory helpers:comparison(),transform(),numeric(),pattern(),booleanOp()Refactored Built-in Operators
All built-in operators now use the new factory helpers, significantly reducing code duplication:
eq,gt,gte,lt,lte) - Usecomparison()helperand,or) - UsebooleanOp()helperadd,subtract,multiply,divide) - Usenumeric()helperupper,lower) - Usetransform()helperlike,ilike) - Usepattern()helperisNull,isUndefined,not) - UsedefineOperatordirectlyTree-Shaking Improvements
/*#__PURE__*/annotations to all factory calls for better tree-shakingNew Exports
Usage Examples
Custom Operator with Factory Helper
Custom Operator with Inline Compile Function
Custom Aggregate
API Design Notes
compileproperty: Named to reflect the two-phase execution - called once during query compilation to create the per-row evaluatorTArgssupports named tuples like[value: number, min: number]for better IDE experienceTypedEvaluatorFactoryfor type safety while remaining compatible with the internalEvaluatorFactoryTests
custom-operators.test.tsandcustom-aggregates.test.tscustom-operators.test-d.tsandcustom-aggregates.test-d.ts